package com.android.gilastv.dialog;

import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.android.baselibrary.dialog.BaseDialogFragment;
import com.android.baselibrary.util.Util;
import com.android.baselibrary.view.GridSpacingItemDecoration;
import com.android.gilastv.R;
import com.android.gilastv.adapter.XuanJiAdapter;
import com.android.gilastv.bean.CommVideoInfo;

import java.util.List;
import java.util.Map;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/8/29.
 */

public class XuanJi_DialogFragment extends BaseDialogFragment {

    @BindView(R.id.recyclerview)
    RecyclerView recyclerview;

    XuanJiAdapter adapter;

    List<CommVideoInfo.VideoSets> videoSetsList;   //集数列表;
    int currentSelectVideoIndex;  //当前集数

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_xuanji;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        recyclerview.setLayoutManager(new GridLayoutManager(mContext,5));
        recyclerview.addItemDecoration(new GridSpacingItemDecoration(5, Util.dip2px(mContext,10),true));
        adapter = new XuanJiAdapter(mContext, callBack);
        recyclerview.setAdapter(adapter);

        adapter.setData(videoSetsList,currentSelectVideoIndex);

    }

    @Override
    protected boolean setCanceledOnTouchBACK() {
        return true;
    }

    @Override
    protected int getShowDirection() {
        return BaseDialogFragment.Direction_FadeIn;
    }

    @Override
    public void setData(Map<String, Object> params) {
        if (params != null) {
            videoSetsList = (List<CommVideoInfo.VideoSets>) params.get("videoSetsList");
            currentSelectVideoIndex = (int) params.get("currentSelectVideoIndex");
        }
    }

    public static BaseDialogFragment showDialog(FragmentActivity activity, Map<String, Object> params) {
        XuanJi_DialogFragment dialogFragment = new XuanJi_DialogFragment();
        dialogFragment.setData(params);
        dialogFragment.show(activity.getSupportFragmentManager(), "");
        return dialogFragment;
    }


//    @OnClick({R.id.ll_share_wx })
//    public void onViewClicked(View view) {
//        switch (view.getId()) {
//            case R.id.ll_share_wx:          //分享-微信
//
//                break;
//        }
//    }


}
